<template>
  <div>
    <van-nav-bar
      :title="active"
      />
    <keep-alive include="car">
      <router-view/>
    </keep-alive>
    <van-tabbar v-model="active" active-color="yellowgreen" :placeholder='true'>
    <van-tabbar-item :to='"/main/"+v.path' v-for="v in tabarr" :key="v.text" :name="v.text" :icon="v.icon">
      {{v.text}}
    </van-tabbar-item>
    
  </van-tabbar>
  </div>
</template>
<script>
export default {
  name:'mains',
  data() {
    return {
        tabarr:[
          {
            text:"首页",
            icon:'home-o',
            path:'index'
          },
          {
            text:"分类",
            icon:'apps-o',
            path:'cate'
          },
          {
            text:"购物车",
            icon:'cart-o',
            path:'car'
          },
          {
            text:"我",
            icon:'user-o',
            path:'my'
          },
        ],
        active:'首页',// 高亮
        // title:'首页',// 标题
    }
  },
  mounted(){
      console.log("我是main");
  },
  computed:{

  },
  methods:{

  },

  watch:{
    $route:{
        handler(n){
          // console.log(n);
          this.active=n.meta.text
        },
        deep:true,
        immediate:true
    }
  }
  
}
</script>
<style scoped>

</style>
